<?php

namespace HelloWeb\LottoBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use HelloWeb\LottoBundle\Entity\Interfaces\LottoInterface;

class LottoForm extends AbstractType implements LottoInterface{
    
    protected $lottoTypes = array();
    
    public function getName(){
        return 'lottoForm';
    }
    
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'HelloWeb\LottoBundle\Entity\Lotto',
            'cascade_validation' =>true,
            'csrf_protection' => false,
        ));
    }
    
    public function buildForm(FormBuilderInterface $builder, array $options){
        $builder
            ->add('title','text',array(
                'required'=>true,
                'max_length'=>20,
                'label'=>'lotto.title'
            ))
            ->add('type',"choice",array(
                'label'=>'lotto.type',
                'expanded'=>false,
                'multiple'=>false,
                'choices'=>$this->getLottoTypes(),
                'required'=>true,
                'empty_value'=>false
            ))
            ->add('date',"text",array(
                'required'=>true,
                'max_length'=>20,
                'label'=>'lotto.date'
            ))
            ->add('save','submit')
            ->add('cancel','button')
            ;
    
    }

    public function getLottoTypes()
    {
        return $this->lottoTypes;
    }

    public function setLottoTypes()
    {
        $this->lottoTypes[LottoInterface::LOTTO_POWERBALL] = LottoInterface::LOTTO_POWERBALL_TITLE;
        $this->lottoTypes[LottoInterface::LOTTO_OZ_LOTTO] = LottoInterface::LOTTO_OZ_LOTTO_TITLE;
        return $this;
    }
 
    
    
}